<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="24" class="custom-title-box">
        <div class="custom-info-title">
          {{getTitleByName(nameOfPermission)}}列表查询
          <el-button link @click="delFav()" style="margin-bottom: 5px;" v-if="userFavorites?.length > 0">
            <svg-icon icon-class="stars" color="#E6A23C" />
          </el-button>
          <el-button link @click="addFav()" style="margin-bottom: 5px;" v-else>
            <svg-icon icon-class="star" />
          </el-button>
        </div>
        <div>
          <el-button v-waves type="success" icon="Search" @click="handleFilter">
            查询
          </el-button>
          <el-button icon="Refresh" @click="handleResetQuery">
            重置
          </el-button>
        </div>
      </el-col>
    </el-row>
    <div class="filter-container">
      <el-form :inline="true" ref="listQuery" :model="listQuery" class="demo-form-inline">
        <el-form-item prop="expenditureKpiId" label="指标单">
          <el-select v-model="listQuery.expenditureKpiId" class="m-2" placeholder="请选择" clearable filterable>
            <el-option key="" label="全部" value="" />
            <el-option v-for="item in expenditureKpiList" :key="item.id" :label="`${item.kpiCode} - ${item.kpiName}`" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item prop="applicationCode" label="申请单号">
          <InputTagDialog v-model="listQuery.applicationCode" placeholder="申请单号" title="填写申请单号" />
        </el-form-item>
        <el-form-item label="申请日期">
          <el-date-picker v-model="listQuery.applicationDateRange"
                          value-format="YYYY-MM-DD"
                          style="width: 300px"
                          type="daterange"
                          range-separator="-"
                          start-placeholder="申请日期开始"
                          end-placeholder="申请日期结束" />
        </el-form-item>
        <el-form-item prop="applicationOrganizationId" label="申请人部门">
          <Organization v-model="listQuery.applicationOrganizationId" keyName="id" keyShow="organizationName" placeholder="申请人部门" title="部门查询" :disabled="useUserStore().organization.organizationType !== '1'" />
        </el-form-item>
        <el-form-item prop="applicationUserId" label="申请人用户">
          <User v-model="listQuery.applicationUserId" keyName="id" keyShow="name" placeholder="用户" title="用户查询" :disabled="useUserStore().organization.organizationType !== '1'" />
        </el-form-item>
        <el-form-item prop="expenditureEconomicId" label="经济分类">
          <el-input v-model="listQuery.expenditureEconomicId" placeholder="经济分类" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="applicationType" label="用款申请单类型">
          <el-select v-model="listQuery.applicationType" class="m-2" placeholder="请选择">
            <el-option key="" label="全部" value="" />
            <el-option v-for="item in getDictList('ExpenditureApplicationType')" :key="item.key" :label="`${item.key} - ${item.value}`" :value="item.key" />
          </el-select>
        </el-form-item>
        <!--
        <el-form-item prop="amount" label="申请金额">
          <el-input v-model="listQuery.amount" placeholder="申请金额" @keyup.enter="handleFilter" />
        </el-form-item>
        -->
        <el-form-item prop="items" label="请款事项">
          <el-input v-model="listQuery.items" placeholder="请款事项" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="reason" label="支出事由">
          <el-input v-model="listQuery.reason" placeholder="支出事由" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="state" label="状态">
          <el-radio-group v-model="listQuery.state">
            <el-radio-button label="" key="">全部</el-radio-button>
            <el-radio-button v-for="(item,index) in getEnumList('ExpenditureApplicationState')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </div>
    <el-row :gutter="20">
      <el-col :span="24" class="custom-title-box">
        <div class="custom-info-title">列表详情</div>
        <div>
          <el-button v-show="checkAuthByCode('')" type="primary" icon="Download" @click="handleExport">
            导出
          </el-button>
          <el-button type="primary" icon="Edit" :disabled="!checkAuthByCode('')" @click="handleAdd">
            新增
          </el-button>
        </div>
      </el-col>
    </el-row>
    <el-divider class="el-divider--horizontal-margin" />
    <el-table v-loading="listLoading"
              :key="tableKey"
              :data="list"
              :row-style="{height: '0'}"
              :cell-style="{padding: '0'}"
              border
              fit
              highlight-current-row
              tooltip-effect="dark"
              @sort-change="handleSortChange"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="39px" />
      <el-table-column align="center" type="index" label="序号" width="60px" />
      <el-table-column v-if="isDebug" align="center" label="ID" prop="id" width="60px" sortable show-overflow-tooltip />
      <el-table-column align="center" label="指标单编码" prop="expenditureKpiId" min-width="200px">
        <template v-slot="{row}"><LabelTag :foreignList="expenditureKpiList" :foreignIds="row.expenditureKpiId" :foreignLabel="'kpiCode'" /></template>
      </el-table-column>
      <el-table-column align="center" label="指标单名称" prop="expenditureKpiId" min-width="200px" show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="expenditureKpiList" :foreignIds="row.expenditureKpiId" :foreignLabel="'kpiName'" /></template>
      </el-table-column>
      <el-table-column align="center" label="申请单号" prop="applicationCode" min-width="140px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><CodeTag :code="row.applicationCode" /></template>
      </el-table-column>
      <el-table-column align="center" label="申请日期" prop="applicationDate" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.applicationDate?.substring(0, 10) }}</template>
      </el-table-column>
      <el-table-column align="center" label="用款申请单类型" prop="applicationType" min-width="200px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('ExpenditureApplicationType')" :dict-key="row.applicationType" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态" prop="state" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('ExpenditureApplicationState')" :enum-key="row.state" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="申请金额" prop="amount" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><MoneyTag :money="row.amount" /></template>
      </el-table-column>

      <el-table-column align="center" label="请款事项" prop="items" min-width="120px" sortable show-overflow-tooltip />
      <el-table-column align="center" label="支出事由" prop="reason" min-width="120px" sortable show-overflow-tooltip />
      <el-table-column align="center" label="申请人部门" prop="applicationOrganizationId" min-width="120px" show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="organizationList" :foreignIds="row.applicationOrganizationId" :foreignLabel="'organizationName'" /></template>
      </el-table-column>
      <el-table-column align="center" label="申请人用户" prop="applicationUserId" min-width="120px" show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="userList" :foreignIds="row.applicationUserId" :foreignLabel="'name'" /></template>
      </el-table-column>
      <el-table-column align="center" label="经济分类" prop="expenditureEconomicId" min-width="220px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="expenditureEconomicList" :foreignIds="row.expenditureEconomicId" :foreignLabel="'name'" /></template>
      </el-table-column>
      <el-table-column align="center" label="备注" prop="remark" min-width="80px" show-overflow-tooltip />
      <el-table-column align="center" label="创建时间" width="180px" prop="createTime" sortable show-overflow-tooltip>
        <template v-slot="{row}"><DateTag :timestamp="row.createTime" /></template>
      </el-table-column>
      <el-table-column align="center" label="最后修改时间" width="180px" prop="updateTime" sortable show-overflow-tooltip>
        <template v-slot="{row}"><DateTag :timestamp="row.updateTime" /></template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="160px" fixed="right">
        <template v-slot="{row}">
          <el-button type="primary" link @click="handleView(row)">查看</el-button>
          <el-button type="primary" link @click="handlePreview(row)">预览</el-button>
          <el-button v-show="checkAuthByCode('') && ['1','2','3','4','5'].includes(row.state)" type="success" link @click="handleApprove(row)">审批流程</el-button>
          <el-button v-show="checkAuthByCode('') && ['0','3','4'].includes(row.state)" type="primary" link @click="handleEdit(row)">编辑</el-button>
          <el-popconfirm confirm-button-text="确定"
                         cancel-button-text="取消"
                         :icon="WarningFilled"
                         icon-color="#626AEF"
                         title="您确定删除么？"
                         @confirm="handleDelete(row)"
                         v-if="checkAuthByCode('') && ['0','3','4'].includes(row.state)">
            <template #reference>
              <el-button type="danger" link>删除</el-button>
            </template>
          </el-popconfirm>
          <el-popconfirm confirm-button-text="确定"
                         cancel-button-text="取消"
                         :icon="InfoFilled"
                         icon-color="#626AEF"
                         title="您确定撤回么？"
                         @confirm="handleRevocation(row)"
                         v-if="checkAuthByCode('') && ['1'].includes(row.state)">
            <template #reference>
              <el-button type="danger" link>撤回</el-button>
            </template>
          </el-popconfirm>
          <el-popconfirm confirm-button-text="确定"
                         cancel-button-text="取消"
                         :icon="InfoFilled"
                         icon-color="#626AEF"
                         title="您确定要完结该事前申请单么？"
                         @confirm="handleComplete(row)"
                         v-if="checkAuthByCode('') && ['2'].includes(row.state)">
            <template #reference>
              <el-button type="primary" link>完结</el-button>
            </template>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-model:total="total" v-model:page="listQuery.pageNum" v-model:limit="listQuery.pageSize" @pagination="getList" />
    <el-dialog v-model="dialogVisible" :title="dialogTypeTitle" width="70%" top="2vh">
      <!--
      <el-form class="my-form" ref="obj" :model="obj" :rules="rules" label-position="right" :disabled="dialogType === 'view'" label-width="auto">
        <el-form-item v-show="isDebug" label="ID">
          <text>{{ obj.id }}</text>
        </el-form-item>
        <el-form-item label="指标单表ID" prop="expenditureKpiId">
          <el-input v-model="obj.expenditureKpiId" type="number" placeholder="请输入指标单表ID" />
        </el-form-item>
        <el-form-item label="申请单号" prop="applicationCode">
          <el-input v-model="obj.applicationCode" placeholder="请输入申请单号，最多输入100个字符" />
        </el-form-item>
        <el-form-item label="申请日期" prop="applicationDate">
          <el-date-picker v-model="obj.applicationDate" placeholder="请输入申请日期" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" />
        </el-form-item>
        <el-form-item label="申请人部门" prop="applicationOrganizationId">
          <el-input v-model="obj.applicationOrganizationId" type="number" placeholder="请输入申请人部门" />
        </el-form-item>
        <el-form-item label="申请人用户" prop="applicationUserId">
          <el-input v-model="obj.applicationUserId" type="number" placeholder="请输入申请人用户" />
        </el-form-item>
        <el-form-item label="用款申请单类型" prop="applicationType">
          <el-input v-model="obj.applicationType" placeholder="请输入类型，最多输入20个字符" />
        </el-form-item>
        <el-form-item label="申请金额" prop="amount">
          <el-input-number v-model="obj.amount" placeholder="请输入申请金额" :precision="2" />
        </el-form-item>
        <el-form-item label="请款事项" prop="items">
          <el-input v-model="obj.items" placeholder="请输入请款事项，最多输入200个字符" />
        </el-form-item>
        <el-form-item label="支出事由" prop="reason">
          <el-input v-model="obj.reason" placeholder="请输入支出事由，最多输入200个字符" />
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-radio-group v-model="obj.state">
            <el-radio-button v-for="(item,index) in getEnumList('ExpenditureApplicationState')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="obj.remark" :autosize="{ minRows: 2, maxRows: 5}" type="textarea" class="textarea-1" />
        </el-form-item>
        <el-form-item label="创建时间">
          <text>{{ obj.createTime ? obj.createTime : '自动生成' }}</text>
        </el-form-item>
        <el-form-item label="最后修改时间">
          <text>{{ obj.updateTime ? obj.updateTime : '自动生成' }}</text>
        </el-form-item>
        <el-form-item v-show="isDebug" label="数据版本">
          <text>{{ obj.version }}</text>
        </el-form-item>
      </el-form>
      <div style="text-align:right;">
        <el-button type="info" icon="Close" @click="dialogVisible=false">关闭</el-button>
        <el-button type="primary" icon="Check" v-show="dialogType !== 'view'" @click="doConfirm('obj')">确定</el-button>
      </div>
      -->
    </el-dialog>
    <el-dialog v-model="dialogPreviewVisible" title="预览" width="80%" top="2vh">
      <expenditureApplicationDetail v-model:expenditureApplicationId="previewObjId" />
      <div style="text-align:right;margin: 1.875rem 0;">
        <el-button type="danger" @click="dialogPreviewVisible=false">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog v-model="dialogApproveVisible" title="审批流程" width="55%" top="2vh">
      <approveTimeline :businessType="approveOrderBusinessTypes().expenditureApplication" :businessId="obj.id" />
      <div style="text-align:right;margin: 1.875rem 0;">
        <el-button type="danger" @click="dialogApproveVisible=false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import baseConfig from '@/mixins/baseConfig'
import {doGet, doPost, doPut, doDelete, doGetDownload} from '@/config/http'
import {
  alertErrorMsg,
  approveOrderBusinessTypes,
  customValidator,
  getListPageSize,
  notifySuccess,
  initListUpdate
} from '@/config/common'
import expenditureApplicationDetail from '@/views/components/expenditure/expenditureApplicationDetail.vue'
import approveTimeline from '@/views/components/base/approveTimeline.vue'
import {getUserId} from "@/config/cookie";
import useUserStore from "@/store/modules/user";
import SvgIcon from "@/components/SvgIcon/index.vue";
import InputTagDialog from "@/components/InputTag/inputTagDialog.vue";
import User from "@/views/components/base/selectUser.vue";
import Organization from "@/views/components/base/selectOrganization.vue";
import initListStore from '@/store/modules/initList'

const emptyObj = {
  expenditureKpiId: null, // 指标单表ID
  applicationCode: null, // 申请单号
  applicationDate: null, // 申请日期
  applicationOrganizationId: null, // 申请人部门
  applicationUserId: null, // 申请人用户
  expenditureEconomicId: null, // 经济分类
  applicationType: null, // 用款申请单类型
  amount: null, // 申请金额
  items: null, // 请款事项
  reason: null, // 支出事由
  state: null, // 状态
  remark: null, // 备注
  id: null,
  createBy: null,
  createTime: null,
  updateBy: null,
  updateTime: null,
  deleted: null,
  version: null,
}

export default {
  name: 'expenditureApplication_nocache',
  mixins: [baseConfig],
  components: {Organization, User, InputTagDialog, SvgIcon, approveTimeline, expenditureApplicationDetail },
  data() {
    return {
      svc: 'icims-api',
      obj: Object.assign({}, emptyObj),
      routes: [],
      dialogVisible: false,
      dialogType: 'add',
      dialogTypeTitle: '新增',
      checkStrictly: false,
      previewObjId: '',
      defaultProps: {
        children: 'children',
        label: 'title'
      },
      tableKey: 0,
      list: null,
      dialogPreviewVisible: false,
      dialogApproveVisible: false,
      total: 0,
      listLoading: false,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        sortField: 'id',
        sortType: 'desc',
        expenditureKpiId: null,
        applicationCode: null,
        applicationDateStart: null,
        applicationDateEnd: null,
        applicationDateRange: [],//
        applicationOrganizationId: useUserStore().organization.organizationType !== '1' ? useUserStore().organization.id : '',
        applicationUserId: useUserStore().organization.organizationType !== '1' ? getUserId() : '',
        expenditureEconomicId: null,
        applicationType: null,
        amount: null,
        items: null,
        reason: null,
        state: null,
        createTimeStart: null,
        createTimeEnd: null,
        updateTimeStart: null,
        updateTimeEnd: null,
      },
      selectionList: [],
      dialogFormVisible: false,
      dialogStatus: '',
      rules: {
        expenditureKpiId: [{ required: true, validator: customValidator, min: 1, max: 20, label: '指标单表ID', trigger: ['blur', 'change'] }],
        applicationCode: [{ required: false, validator: customValidator, min: 0, max: 100, label: '申请单号', trigger: ['blur', 'change'] }],
        applicationDate: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申请日期', trigger: ['blur', 'change'] }],
        applicationOrganizationId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申请人部门', trigger: ['blur', 'change'] }],
        applicationUserId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申请人用户', trigger: ['blur', 'change'] }],
        expenditureEconomicId: [{ required: false, validator: customValidator, min: 0, max: 200, label: '经济分类', trigger: ['blur', 'change'] }],
        applicationType: [{ required: false, validator: customValidator, min: 0, max: 20, label: '用款申请单类型', trigger: ['blur', 'change'] }],
        amount: [{ required: false, validator: customValidator, min: 0, max: 13, label: '申请金额', trigger: ['blur', 'change'] }],
        items: [{ required: false, validator: customValidator, min: 0, max: 200, label: '请款事项', trigger: ['blur', 'change'] }],
        reason: [{ required: false, validator: customValidator, min: 0, max: 200, label: '支出事由', trigger: ['blur', 'change'] }],
        state: [{ required: false, validator: customValidator, min: 0, max: 20, label: '状态', trigger: ['blur', 'change'] }],
        remark: [{ required: false, validator: customValidator, min: 0, max: 0, label: '备注', trigger: ['blur', 'change'] }],
      },
      governmentList: initListStore().governmentList,
      organizationList: initListStore().organizationList,
      userList: initListStore().userList,
      expenditurePtypeList: initListStore().expenditurePtypeList,//项目类型
      expenditureFunctionalList: initListStore().expenditureFunctionalList,//功能分类
      expenditureEconomicList:initListStore().expenditureEconomicList,//经济分类
      expenditureFiscalList: initListStore().expenditureFiscalList,//财政项目
      expenditureSubjectList: initListStore().expenditureSubjectList,//会计科目
      expenditureKpiList: initListStore().expenditureKpiList,//指标单
    }
  },
  computed: {
    routesData() {
      return this.routes
    },
  },
  created() {
    this.nameOfPermission = 'expenditureApplication'
    this.getFavorite(this.nameOfPermission)?.then(res => this.userFavorites = res)
    this.getList()
    // this.initList()
  },
  methods: {
    approveOrderBusinessTypes,
    useUserStore,
    // async initList() {
    //   let p1 = doGet(this.svc, '/government/page', {pageSize: getListPageSize()}, false)
    //   let p2 = doGet(this.svc, '/organization/page', {pageSize: getListPageSize()}, false)
    //   let p3 = doGet(this.svc, '/user/page', {pageSize: getListPageSize()}, false)
    //   let p4 = doGet(this.svc, '/expenditure-ptype/page', {pageSize: getListPageSize()}, false)
    //   let p5 = doGet(this.svc, '/expenditure-functional/page', {pageSize: getListPageSize()}, false)
    //   let p6 = doGet(this.svc, '/expenditure-economic/page', {pageSize: getListPageSize()}, false)
    //   let p7 = doGet(this.svc, '/expenditure-fiscal/page', {pageSize: getListPageSize()}, false)
    //   let p8 = doGet(this.svc, '/expenditure-subject/page', {pageSize: getListPageSize()}, false)
    //   let p9 = doGet(this.svc, '/expenditure-kpi/page', {pageSize: getListPageSize()}, false)
    //   let resArray = await Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9])
    //   this.governmentList = resArray[0]['records']
    //   this.organizationList = resArray[1]['records']
    //   this.userList = resArray[2]['records']
    //   this.expenditurePtypeList = resArray[3]['records']
    //   this.expenditureFunctionalList = resArray[4]['records']
    //   this.expenditureEconomicList = resArray[5]['records']
    //   this.expenditureFiscalList = resArray[6]['records']
    //   this.expenditureSubjectList = resArray[7]['records']
    //   this.expenditureKpiList = resArray[8]['records']
    // },
    getList() {
      this.listLoading = true
      this.listQuery.applicationDateStart = ''
      this.listQuery.applicationDateEnd = ''
      if (this.listQuery.applicationDateRange) {
        this.listQuery.applicationDateStart = this.listQuery.applicationDateRange[0]
        this.listQuery.applicationDateEnd = this.listQuery.applicationDateRange[1]
      }
      doGet(this.svc, '/expenditure-application/page', this.listQuery).then(res => {
        this.listLoading = false
        this.list = res['records']
        this.total = parseInt(res['total'])
      }).catch(e => {
        console.error(e)
        this.listLoading = false
      })
    },
    handleResetQuery() {
      this.resetForm("listQuery")
      this.listQuery.applicationDateStart = ''
      this.listQuery.applicationDateEnd = ''
      this.listQuery.applicationDateRange = []
    },
    handleFilter() {
      this.listQuery.pageNum = 1
      this.getList()
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: '操作Success',
        type: 'success'
      })
      row.status = status
    },
    handleSelectionChange(data) {
      this.selectionList = data
    },
    handleSortChange(data) {
      const { prop, order } = data
      this.listQuery.sortField = prop
      this.listQuery.sortType = order === 'ascending' ? 'asc' : 'desc'
      this.handleFilter()
    },
    handlePreview(row) {
      this.previewObjId = row.id
      this.dialogPreviewVisible = true
    },
    handleApprove(row) {
      this.obj = Object.assign({}, row)
      this.dialogApproveVisible = true
    },
    handleEdit(row) {
      this.goTargetByName('expenditureApplicationEdit', {id: row.id, oper: 'edit'})
    },
    handleView(row) {
      this.goTargetByName('expenditureApplicationEdit', {id: row.id, oper: 'view'})
    },
    handleAdd() {
      this.goTargetByName('expenditureApplicationEdit', {oper: 'add'})
    },
    handleExport() {
      doGetDownload(this.svc, '/expenditure-application/export', this.listQuery)
    },
    handleDelete(row) {
      doDelete(this.svc, '/expenditure-application/' + row.id, {}).then(_ => {
        notifySuccess('操作成功')
        this.getList()
        initListUpdate('expenditureApplicationList', '/expenditure-application/page')
      })
    },
    handleRevocation(row) {
      doPost(this.svc, '/customExpenditureExpenses/revocationExpenditureApplication/' + row.id, {}).then(_ => {
        notifySuccess('操作成功')
        this.getList()
      })
    },
    handleComplete(row) {
      doGet(this.svc, '/expenditure-reimbursement/page', {expenditureApplicationId: row.id, state: '0'}, false).then(res => {
        console.log('res',res)
        let count = parseInt(res['total'])
        if (count === 0) {
          this.doComplete(row)
          return
        }
        this.$confirm('该申请单有' + count + '条报账单尚未提交，确定要强制完结吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(_ => {
          this.doComplete(row)
        })
      })
    },
    doComplete(row) {
      doPost(this.svc, `/customExpenditureExpenses/completeExpenditureApplication/${row.id}`, {}).then(() => {
        notifySuccess('操作成功')
        this.getList()
      })
    },
    async doConfirm(formName) {
      let v = await this.$refs[formName].validate().catch((err)=>{return err})
      if (v !== true) {
        alertErrorMsg('表单验证不通过，请检查数据。')
        return
      }
      if (this.dialogType === 'edit') {
        doPut(this.svc, '/expenditure-application/modify', this.obj).then(() => {
          notifySuccess('操作成功')
          this.getList()
          this.dialogVisible = false
        })
      } else if (this.dialogType === 'add') {
        doPost(this.svc, '/expenditure-application/add', this.obj).then(() => {
          notifySuccess('操作成功')
          this.getList()
          this.dialogVisible = false
        })
      }
    }
  }
}
</script>
